package edu.drexel.jrexel2d.physics;


public class Math {
	
	public static float CalculatePositionCoordinate(float inPosition, double inDelta, double inVelocity, double inAcceleration){
		return (float)(inPosition + (inDelta * inVelocity) + (0.5*java.lang.Math.pow(inDelta, 2)*inAcceleration));		
	} 
	
	public static double CalculateVelocityComponent(double inVelocity, double inDelta, double inAcceleration){
		return (inVelocity + (inDelta * inAcceleration));
	}
	
    public static double ElasticCollision1D(double vel_1, int mass_1, double vel_2, int mass_2){
		
		double newVelocity = 0.0;
		
		if((mass_1 + mass_2) != 0.0){
			newVelocity = ( ((mass_1 - mass_2)*vel_1) + (2*mass_2*vel_2) ) / (mass_1 + mass_2);
		}
		else{
			newVelocity = 1.0;
		}
		
		return newVelocity;
	}

}
